/***********************************************************************************************************************************
 * Name:	Replication_Purge-History.sql
 * Author:	Frank Figearo (frank@sqlnerd.me)
 * Summary:	Deletes all history records for all replication jobs.
 */
SET IMPLICIT_TRANSACTIONS OFF; WHILE 0 < @@TRANCOUNT ROLLBACK;
GO
SELECT tsql_command= N'EXECUTE msdb.dbo.sp_purge_jobhistory @job_id= ''' + CAST(j.job_id AS NVARCHAR(36)) + ''''
  FROM sysjobs j
	INNER JOIN syscategories c ON (j.category_id = c.category_id)
  WHERE c.name LIKE 'REPL-%'
GO
